<script setup>
import {
    computed,
    getCurrentInstance,
    inject,
    onMounted,
    provide,
    ref,
    useSlots
} from 'vue'

// 格式化
import { VXETable } from 'vxe-table'
import XEUtils from 'xe-utils'

// 格式化日期，默认 yyyy-MM-dd
VXETable.formats.add('date', {
    cellFormatMethod ({ cellValue }, format) {
        return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd')
    }
})
// 四舍五入金额，每隔3位逗号分隔，默认2位数
VXETable.formats.add('amount', {
    cellFormatMethod ({ cellValue }, digits = 2) {
        return XEUtils.commafy(XEUtils.toNumber(cellValue), { digits })
    }
})
// 格式化银行卡，默认每4位空格隔开
VXETable.formats.add('bankcard', {
    cellFormatMethod ({ cellValue }) {
        return XEUtils.commafy(XEUtils.toValueString(cellValue), { spaceNumber: 4, separator: ' ' })
    }
})
// 向下舍入,默认两位数
VXETable.formats.add('cutNumber', {
    cellFormatMethod ({ cellValue }, digits = 2) {
        return XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
    }
})
// 四舍五入,默认两位数
VXETable.formats.add('fixedNumber', {
    cellFormatMethod ({ cellValue }, digits = 2) {
        return XEUtils.toFixed(XEUtils.round(cellValue, digits), digits)
    }
})
// 格式化性别
VXETable.formats.add('sex', {
    cellFormatMethod ({ cellValue }) {
        return cellValue ? (cellValue === '1' ? '男' : '女') : ''
    }
})

const slots = useSlots()
/**
 * 从VxeTable继承过来的事件，挂载到当前组件上，不能通过Object.keys(VxeTable instance)获取，vue做了限制，返回的keys是空
 */
const extendEvents = [
    'getRefMaps',
    'getComputeMaps',
    'openExport',
    'openPrint',
    'exportData',
    'openImport',
    'importData',
    'saveFile',
    'readFile',
    'importByFile',
    'print',
    'clearValidate',
    'fullValidate',
    'validate',
    'dispatchEvent',
    'clearAll',
    'syncData',
    'updateData',
    'loadData',
    'reloadData',
    'reloadRow',
    'loadTreeChildren',
    'loadColumn',
    'reloadColumn',
    'getRowNode',
    'getColumnNode',
    'getRowSeq',
    'getRowIndex',
    'getVTRowIndex',
    'getVMRowIndex',
    'getColumnIndex',
    'getVTColumnIndex',
    'getVMColumnIndex',
    'createData',
    'createRow',
    'revertData',
    'clearData',
    'isInsertByRow',
    'removeInsertRow',
    'isUpdateByRow',
    'getColumns',
    'getColumnById',
    'getColumnByField',
    'getTableColumn',
    'getData',
    'getCheckboxRecords',
    'getParentRow',
    'getRowById',
    'getRowid',
    'getTableData',
    'setColumnFixed',
    'clearColumnFixed',
    'hideColumn',
    'showColumn',
    'setColumnWidth',
    'getColumnWidth',
    'resetColumn',
    'refreshColumn',
    'refreshScroll',
    'recalculate',
    'openTooltip',
    'closeTooltip',
    'isAllCheckboxChecked',
    'isAllCheckboxIndeterminate',
    'getCheckboxIndeterminateRecords',
    'setCheckboxRow',
    'isCheckedByCheckboxRow',
    'isIndeterminateByCheckboxRow',
    'toggleCheckboxRow',
    'setAllCheckboxRow',
    'getRadioReserveRecord',
    'clearRadioReserve',
    'getCheckboxReserveRecords',
    'clearCheckboxReserve',
    'toggleAllCheckboxRow',
    'clearCheckboxRow',
    'setCurrentRow',
    'isCheckedByRadioRow',
    'setRadioRow',
    'clearCurrentRow',
    'clearRadioRow',
    'getCurrentRecord',
    'getRadioRecord',
    'getCurrentColumn',
    'setCurrentColumn',
    'clearCurrentColumn',
    'sort',
    'clearSort',
    'isSort',
    'getSortColumns',
    'closeFilter',
    'isActiveFilterByColumn',
    'isFilter',
    'isRowExpandLoaded',
    'clearRowExpandLoaded',
    'reloadRowExpand',
    'reloadExpandContent',
    'toggleRowExpand',
    'setAllRowExpand',
    'setRowExpand',
    'isExpandByRow',
    'clearRowExpand',
    'clearRowExpandReserve',
    'getRowExpandRecords',
    'getTreeExpandRecords',
    'isTreeExpandLoaded',
    'clearTreeExpandLoaded',
    'reloadTreeExpand',
    'reloadTreeChilds',
    'toggleTreeExpand',
    'setAllTreeExpand',
    'setTreeExpand',
    'isTreeExpandByRow',
    'clearTreeExpand',
    'clearTreeExpandReserve',
    'getScroll',
    'scrollTo',
    'scrollToRow',
    'scrollToColumn',
    'clearScroll',
    'updateFooter',
    'updateStatus',
    'setMergeCells',
    'removeMergeCells',
    'getMergeCells',
    'clearMergeCells',
    'setMergeFooterItems',
    'removeMergeFooterItems',
    'getMergeFooterItems',
    'clearMergeFooterItems',
    'updateCellAreas',
    'focus',
    'blur',
    'connect',
    'getSetupOptions',
    'updateAfterDataIndex',
    'callSlot',
    'getParentElem',
    'getParentHeight',
    'getExcludeHeight',
    'defineField',
    'handleTableData',
    'cacheRowMap',
    'analyColumnWidth',
    'saveCustomResizable',
    'saveCustomFixed',
    'saveCustomVisible',
    'handleCustom',
    'handleUpdateDataQueue',
    'handleRefreshColumnQueue',
    'preventEvent',
    'checkSelectionStatus',
    'handleSelectRow',
    'triggerHeaderHelpEvent',
    'triggerHeaderTooltipEvent',
    'triggerBodyTooltipEvent',
    'triggerFooterTooltipEvent',
    'handleTargetLeaveEvent',
    'triggerHeaderCellClickEvent',
    'triggerHeaderCellDblclickEvent',
    'triggerCellClickEvent',
    'triggerCellDblclickEvent',
    'handleToggleCheckRowEvent',
    'triggerCheckRowEvent',
    'triggerCheckAllEvent',
    'triggerRadioRowEvent',
    'triggerCurrentRowEvent',
    'triggerRowExpandEvent',
    'triggerTreeExpandEvent',
    'triggerSortEvent',
    'triggerScrollXEvent',
    'triggerScrollYEvent',
    'scrollToTreeRow',
    'updateScrollYStatus',
    'updateScrollXSpace',
    'updateScrollYSpace',
    'updateScrollXData',
    'updateScrollYData',
    'checkScrolling',
    'updateZindex',
    'handleCheckedCheckboxRow',
    'triggerHoverEvent',
    'setHoverRow',
    'clearHoverRow',
    'getCell',
    'getCellLabel',
    'findRowIndexOf',
    'eqRow',
    'openFilter',
    'setFilter',
    'clearFilter',
    'getCheckedFilters',
    'checkFilterOptions',
    'triggerFilterEvent',
    'handleClearFilter',
    'confirmFilterEvent',
    'closeMenu',
    'moveCtxMenu',
    'handleGlobalContextmenuEvent',
    'ctxMenuMouseoverEvent',
    'ctxMenuMouseoutEvent',
    'ctxMenuLinkEvent',
    'insert',
    'insertAt',
    'remove',
    'removeCheckboxRow',
    'removeRadioRow',
    'removeCurrentRow',
    'getRecordset',
    'getInsertRecords',
    'getRemoveRecords',
    'getUpdateRecords',
    'getActiveRecord',
    'getEditRecord',
    'getSelectedCell',
    'clearActived',
    'clearEdit',
    'clearSelected',
    'isActiveByRow',
    'isEditByRow',
    'setActiveRow',
    'setEditRow',
    'setActiveCell',
    'setEditCell',
    'setSelectCell',
    'handleActived',
    'handleFocus',
    'handleSelected',
    'addCellSelectedClass',
    'moveTabSelected',
    'moveCurrentRow',
    'moveSelected',
    'triggerHeaderCellMousedownEvent',
    'triggerCellMousedownEvent',
    'validCellRules',
    'hasCellRules',
    'triggerValidate',
    'showValidTooltip',
    'renderVN',
    'getRefMaps',
    'getComputeMaps',
    'openExport',
    'openPrint',
    'exportData',
    'openImport',
    'importData',
    'saveFile',
    'readFile',
    'importByFile',
    'print',
    'clearValidate',
    'fullValidate',
    'validate',
    'dispatchEvent',
    'clearAll',
    'syncData',
    'updateData',
    'loadData',
    'reloadData',
    'reloadRow',
    'loadTreeChildren',
    'loadColumn',
    'reloadColumn',
    'getRowNode',
    'getColumnNode',
    'getRowSeq',
    'getRowIndex',
    'getVTRowIndex',
    'getVMRowIndex',
    'getColumnIndex',
    'getVTColumnIndex',
    'getVMColumnIndex',
    'createData',
    'createRow',
    'revertData',
    'clearData',
    'isInsertByRow',
    'removeInsertRow',
    'isUpdateByRow',
    'getColumns',
    'getColumnById',
    'getColumnByField',
    'getTableColumn',
    'getData',
    'getCheckboxRecords',
    'getParentRow',
    'getRowById',
    'getRowid',
    'getTableData',
    'setColumnFixed',
    'clearColumnFixed',
    'hideColumn',
    'showColumn',
    'setColumnWidth',
    'getColumnWidth',
    'resetColumn',
    'refreshColumn',
    'refreshScroll',
    'recalculate',
    'openTooltip',
    'closeTooltip',
    'isAllCheckboxChecked',
    'isAllCheckboxIndeterminate',
    'getCheckboxIndeterminateRecords',
    'setCheckboxRow',
    'isCheckedByCheckboxRow',
    'isIndeterminateByCheckboxRow',
    'toggleCheckboxRow',
    'setAllCheckboxRow',
    'getRadioReserveRecord',
    'clearRadioReserve',
    'getCheckboxReserveRecords',
    'clearCheckboxReserve',
    'toggleAllCheckboxRow',
    'clearCheckboxRow',
    'setCurrentRow',
    'isCheckedByRadioRow',
    'setRadioRow',
    'clearCurrentRow',
    'clearRadioRow',
    'getCurrentRecord',
    'getRadioRecord',
    'getCurrentColumn',
    'setCurrentColumn',
    'clearCurrentColumn',
    'sort',
    'clearSort',
    'isSort',
    'getSortColumns',
    'closeFilter',
    'isActiveFilterByColumn',
    'isFilter',
    'isRowExpandLoaded',
    'clearRowExpandLoaded',
    'reloadRowExpand',
    'reloadExpandContent',
    'toggleRowExpand',
    'setAllRowExpand',
    'setRowExpand',
    'isExpandByRow',
    'clearRowExpand',
    'clearRowExpandReserve',
    'getRowExpandRecords',
    'getTreeExpandRecords',
    'isTreeExpandLoaded',
    'clearTreeExpandLoaded',
    'reloadTreeExpand',
    'reloadTreeChilds',
    'toggleTreeExpand',
    'setAllTreeExpand',
    'setTreeExpand',
    'isTreeExpandByRow',
    'clearTreeExpand',
    'clearTreeExpandReserve',
    'getScroll',
    'scrollTo',
    'scrollToRow',
    'scrollToColumn',
    'clearScroll',
    'updateFooter',
    'updateStatus',
    'setMergeCells',
    'removeMergeCells',
    'getMergeCells',
    'clearMergeCells',
    'setMergeFooterItems',
    'removeMergeFooterItems',
    'getMergeFooterItems',
    'clearMergeFooterItems',
    'updateCellAreas',
    'focus',
    'blur',
    'connect',
    'getSetupOptions',
    'updateAfterDataIndex',
    'callSlot',
    'getParentElem',
    'getParentHeight',
    'getExcludeHeight',
    'defineField',
    'handleTableData',
    'cacheRowMap',
    'analyColumnWidth',
    'saveCustomResizable',
    'saveCustomFixed',
    'saveCustomVisible',
    'handleCustom',
    'handleUpdateDataQueue',
    'handleRefreshColumnQueue',
    'preventEvent',
    'checkSelectionStatus',
    'handleSelectRow',
    'triggerHeaderHelpEvent',
    'triggerHeaderTooltipEvent',
    'triggerBodyTooltipEvent',
    'triggerFooterTooltipEvent',
    'handleTargetLeaveEvent',
    'triggerHeaderCellClickEvent',
    'triggerHeaderCellDblclickEvent',
    'triggerCellClickEvent',
    'triggerCellDblclickEvent',
    'handleToggleCheckRowEvent',
    'triggerCheckRowEvent',
    'triggerCheckAllEvent',
    'triggerRadioRowEvent',
    'triggerCurrentRowEvent',
    'triggerRowExpandEvent',
    'triggerTreeExpandEvent',
    'triggerSortEvent',
    'triggerScrollXEvent',
    'triggerScrollYEvent',
    'scrollToTreeRow',
    'updateScrollYStatus',
    'updateScrollXSpace',
    'updateScrollYSpace',
    'updateScrollXData',
    'updateScrollYData',
    'checkScrolling',
    'updateZindex',
    'handleCheckedCheckboxRow',
    'triggerHoverEvent',
    'setHoverRow',
    'clearHoverRow',
    'getCell',
    'getCellLabel',
    'findRowIndexOf',
    'eqRow',
    'openFilter',
    'setFilter',
    'clearFilter',
    'getCheckedFilters',
    'checkFilterOptions',
    'triggerFilterEvent',
    'handleClearFilter',
    'confirmFilterEvent',
    'closeMenu',
    'moveCtxMenu',
    'handleGlobalContextmenuEvent',
    'ctxMenuMouseoverEvent',
    'ctxMenuMouseoutEvent',
    'ctxMenuLinkEvent',
    'insert',
    'insertAt',
    'remove',
    'removeCheckboxRow',
    'removeRadioRow',
    'removeCurrentRow',
    'getRecordset',
    'getInsertRecords',
    'getRemoveRecords',
    'getUpdateRecords',
    'getActiveRecord',
    'getEditRecord',
    'getSelectedCell',
    'clearActived',
    'clearEdit',
    'clearSelected',
    'isActiveByRow',
    'isEditByRow',
    'setActiveRow',
    'setEditRow',
    'setActiveCell',
    'setEditCell',
    'setSelectCell',
    'handleActived',
    'handleFocus',
    'handleSelected',
    'addCellSelectedClass',
    'moveTabSelected',
    'moveCurrentRow',
    'moveSelected',
    'triggerHeaderCellMousedownEvent',
    'triggerCellMousedownEvent',
    'validCellRules',
    'hasCellRules',
    'triggerValidate',
    'showValidTooltip',
    'renderVN',
    'getRefMaps',
    'getComputeMaps',
    'openExport',
    'openPrint',
    'exportData',
    'openImport',
    'importData',
    'saveFile',
    'readFile',
    'importByFile',
    'print',
    'clearValidate',
    'fullValidate',
    'validate',
    'dispatchEvent',
    'clearAll',
    'syncData',
    'updateData',
    'loadData',
    'reloadData',
    'reloadRow',
    'loadTreeChildren',
    'loadColumn',
    'reloadColumn',
    'getRowNode',
    'getColumnNode',
    'getRowSeq',
    'getRowIndex',
    'getVTRowIndex',
    'getVMRowIndex',
    'getColumnIndex',
    'getVTColumnIndex',
    'getVMColumnIndex',
    'createData',
    'createRow',
    'revertData',
    'clearData',
    'isInsertByRow',
    'removeInsertRow',
    'isUpdateByRow',
    'getColumns',
    'getColumnById',
    'getColumnByField',
    'getTableColumn',
    'getData',
    'getCheckboxRecords',
    'getParentRow',
    'getRowById',
    'getRowid',
    'getTableData',
    'setColumnFixed',
    'clearColumnFixed',
    'hideColumn',
    'showColumn',
    'setColumnWidth',
    'getColumnWidth',
    'resetColumn',
    'refreshColumn',
    'refreshScroll',
    'recalculate',
    'openTooltip',
    'closeTooltip',
    'isAllCheckboxChecked',
    'isAllCheckboxIndeterminate',
    'getCheckboxIndeterminateRecords',
    'setCheckboxRow',
    'isCheckedByCheckboxRow',
    'isIndeterminateByCheckboxRow',
    'toggleCheckboxRow',
    'setAllCheckboxRow',
    'getRadioReserveRecord',
    'clearRadioReserve',
    'getCheckboxReserveRecords',
    'clearCheckboxReserve',
    'toggleAllCheckboxRow',
    'clearCheckboxRow',
    'setCurrentRow',
    'isCheckedByRadioRow',
    'setRadioRow',
    'clearCurrentRow',
    'clearRadioRow',
    'getCurrentRecord',
    'getRadioRecord',
    'getCurrentColumn',
    'setCurrentColumn',
    'clearCurrentColumn',
    'sort',
    'clearSort',
    'isSort',
    'getSortColumns',
    'closeFilter',
    'isActiveFilterByColumn',
    'isFilter',
    'isRowExpandLoaded',
    'clearRowExpandLoaded',
    'reloadRowExpand',
    'reloadExpandContent',
    'toggleRowExpand',
    'setAllRowExpand',
    'setRowExpand',
    'isExpandByRow',
    'clearRowExpand',
    'clearRowExpandReserve',
    'getRowExpandRecords',
    'getTreeExpandRecords',
    'isTreeExpandLoaded',
    'clearTreeExpandLoaded',
    'reloadTreeExpand',
    'reloadTreeChilds',
    'toggleTreeExpand',
    'setAllTreeExpand',
    'setTreeExpand',
    'isTreeExpandByRow',
    'clearTreeExpand',
    'clearTreeExpandReserve',
    'getScroll',
    'scrollTo',
    'scrollToRow',
    'scrollToColumn',
    'clearScroll',
    'updateFooter',
    'updateStatus',
    'setMergeCells',
    'removeMergeCells',
    'getMergeCells',
    'clearMergeCells',
    'setMergeFooterItems',
    'removeMergeFooterItems',
    'getMergeFooterItems',
    'clearMergeFooterItems',
    'updateCellAreas',
    'focus',
    'blur',
    'connect',
    'getSetupOptions',
    'updateAfterDataIndex',
    'callSlot',
    'getParentElem',
    'getParentHeight',
    'getExcludeHeight',
    'defineField',
    'handleTableData',
    'cacheRowMap',
    'analyColumnWidth',
    'saveCustomResizable',
    'saveCustomFixed',
    'saveCustomVisible',
    'handleCustom',
    'handleUpdateDataQueue',
    'handleRefreshColumnQueue',
    'preventEvent',
    'checkSelectionStatus',
    'handleSelectRow',
    'triggerHeaderHelpEvent',
    'triggerHeaderTooltipEvent',
    'triggerBodyTooltipEvent',
    'triggerFooterTooltipEvent',
    'handleTargetLeaveEvent',
    'triggerHeaderCellClickEvent',
    'triggerHeaderCellDblclickEvent',
    'triggerCellClickEvent',
    'triggerCellDblclickEvent',
    'handleToggleCheckRowEvent',
    'triggerCheckRowEvent',
    'triggerCheckAllEvent',
    'triggerRadioRowEvent',
    'triggerCurrentRowEvent',
    'triggerRowExpandEvent',
    'triggerTreeExpandEvent',
    'triggerSortEvent',
    'triggerScrollXEvent',
    'triggerScrollYEvent',
    'scrollToTreeRow',
    'updateScrollYStatus',
    'updateScrollXSpace',
    'updateScrollYSpace',
    'updateScrollXData',
    'updateScrollYData',
    'checkScrolling',
    'updateZindex',
    'handleCheckedCheckboxRow',
    'triggerHoverEvent',
    'setHoverRow',
    'clearHoverRow',
    'getCell',
    'getCellLabel',
    'findRowIndexOf',
    'eqRow',
    'openFilter',
    'setFilter',
    'clearFilter',
    'getCheckedFilters',
    'checkFilterOptions',
    'triggerFilterEvent',
    'handleClearFilter',
    'confirmFilterEvent',
    'closeMenu',
    'moveCtxMenu',
    'handleGlobalContextmenuEvent',
    'ctxMenuMouseoverEvent',
    'ctxMenuMouseoutEvent',
    'ctxMenuLinkEvent',
    'insert',
    'insertAt',
    'remove',
    'removeCheckboxRow',
    'removeRadioRow',
    'removeCurrentRow',
    'getRecordset',
    'getInsertRecords',
    'getRemoveRecords',
    'getUpdateRecords',
    'getActiveRecord',
    'getEditRecord',
    'getSelectedCell',
    'clearActived',
    'clearEdit',
    'clearSelected',
    'isActiveByRow',
    'isEditByRow',
    'setActiveRow',
    'setEditRow',
    'setActiveCell',
    'setEditCell',
    'setSelectCell',
    'handleActived',
    'handleFocus',
    'handleSelected',
    'addCellSelectedClass',
    'moveTabSelected',
    'moveCurrentRow',
    'moveSelected',
    'triggerHeaderCellMousedownEvent',
    'triggerCellMousedownEvent',
    'validCellRules',
    'hasCellRules',
    'triggerValidate',
    'showValidTooltip',
    'renderVN'
]

const props = defineProps({
    border: {
        type: Boolean,
        default: true
    },
    height: {
        type: [String, Number],
        default: 'auto'
    },
    editConfig: {
        type: Object,
        default: () => ({})
    },
    columnConfig: {
        type: Object,
        default: () => ({})
    },
    showHeaderOverflow: {
        type: [Boolean, String],
        default: 'tooltip'
    },
    showOverflow: {
        type: [Boolean, String],
        default: 'tooltip'
    },
    rowConfig: {
        type: Object,
        default: () => ({})
    },
    align: {
        type: String,
        default: 'center'
    },
    startIndex: {
        type: Number
    },
    seqConfig: {
        type: Object,
        default: () => ({})
    },
    onHeaderCellClick: {
        type: Function
    },
    /** 是否开启排序功能，使用自带的排序逻辑，如果想自定义排序的话，将该属性设为false */
    sortable: {
        type: Boolean,
        default: true
    }
})

const editConfig = computed(() => {
    return Object.assign(
        {},
        {
            trigger: 'manual',
            mode: 'cell',
            showStatus: true,
            //强制要求点击取消按钮退出编辑状态，否则点其他位置就退出编辑了，但是不执行 exitEditState 函数，currentColumn的值不重置，
            //导致列的宽度也不恢复
            autoClear: false,
            beforeEditMethod({ column }) {
                return currentEditingColumn.value == column.field || currentEditingColumn.value === "_all"
            }
        },
        props.editConfig
    )
})

const columnConfig = computed(() => {
    return Object.assign(
        {},
        {
            resizable: true
        },
        props.columnConfig
    )
})

const rowConfig = computed(() => {
    return Object.assign(
        {},
        {
            isHover: true,
            isCurrent: true
        },
        props.rowConfig
    )
})

const seqConfig = computed(() => {
    return Object.assign(
        {},
        {
            startIndex: props.startIndex
        },
        props.seqConfig
    )
})

const currentPage = inject('currentPage')
const table = ref(null)

onMounted(() => {
    const instance = getCurrentInstance()
    if (table?.value && instance != null) {
        extendEvents.forEach((k) => {
            instance[k] = table.value[k]
        })
    }
})

/**
 * 处理排序
 * @param column
 */
function handleSort(column) {
    if (column.sortable && currentPage) {
        currentPage.exposed.setSort([
            {
                sortColumn: column.field,
                sortType: column.order
            }
        ])
    }
}

function handleHeaderCellClick(args) {
    if (props.onHeaderCellClick) {
        props.onHeaderCellClick(args)
    }
    if (props.sortable) {
        handleSort(args.column)
    }
}

/**
 * 当前正在编辑的列
 */
const currentEditingColumn = ref(null)
const currentEditValue = ref(null)

/**
 * 处理单元格被双击的事件
 * @param row
 * @param column
 */
function handleCellDblClick(args) {
    currentEditingColumn.value = args.column.field
    table.value?.setEditCell(args.row, args.column.field)
    currentEditValue.value = args.row[args.column.field]
}

/**
 * 退出编辑状态
 */
function exitEditState() {
    table.value?.clearEdit()
    currentEditingColumn.value = null
}

/** 给子组件提供的数据和方法 start */
provide('tableInstance', table)
provide('exitEditState', exitEditState)
provide('currentEditingColumn', currentEditingColumn)
provide('currentEditValue', currentEditValue)
/** 给子组件提供的数据和方法 end */

defineExpose({
    ...extendEvents.reduce((acc, k) => {
        acc[k] = (...args) => {
            table.value[k](...args)
        }
        return acc
    }, {})
})
</script>

<template>
    <vxe-table
        ref="table"
        :height="height"
        :border="border"
        :column-config="columnConfig"
        :show-header-overflow="showHeaderOverflow"
        :show-overflow="showOverflow"
        :row-config="rowConfig"
        :align="align"
        :seq-config="seqConfig"
        :edit-config="editConfig"
        @header-cell-click="handleHeaderCellClick"
        @cell-dblclick="handleCellDblClick"
        keep-source
    >
        <template v-for="(_item, key) in slots" :key="key" #[key]="data">
            <slot :name="key" v-bind="data ?? {}" />
        </template>
    </vxe-table>
</template>

<style scoped></style>
